<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

if (!defined('DS')) define('DS', DIRECTORY_SEPARATOR);

class Menus extends OC_Controller {

	function __construct()
	{
		parent::__construct();
		$this->load->model('menus/menus_model','mm');
	}

	function _remap($method, $params = array())
	{
		parent::_remap($method, $params);
		
		if (method_exists($this, $method))
			return call_user_func_array(array($this, $method), $params);
		else
			show_404();
	}

	function init_header()
	{
		$this->header['jeasyui'] 	= TRUE;
		$this->header['parent'] 	= $this->mm->get_menu_all()->rows;		
		$this->header['source_bot'] = array(
			script_tag(site_url('menus/themescript/moment.js')),
			script_tag(site_url('menus/themescript/app/menus.js'))
		);
	}

	function index()
	{
		$this->init_header();
		$this->header['nav'] = 'menus';
		$this->header['pagetitle'] = 'Menu';
		$this->view('menus/menus_view');
	}

	function load_data()
	{
		$params = $this->input->post();
		$result = $this->mm->get_all($params);
		print(json_encode($result));
	}

	function save_data()
	{
		$post = $this->input->post();
		if (empty($post['id'])) {
			unset($post['id']);
			$this->mm->add($post);
		} else {
			$this->mm->edit($post, array(
				'id' => $post['id']
			));
		}
		
		print(json_encode(array(
			'success' => TRUE
		)));
	}

	function delete_data()
	{
		$post = $this->input->post();
		$this->mm->delete(array('id' => $post['id']));
		print(json_encode(array(
			'success' => TRUE
		)));
	}

}

/* End of file menus.php */
/* Location: .//D/OemahCode/hann/module_admin/menus/controllers/menus.php */